package com.多线程07.demo23;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo01 {

    public static void main(String[] args) {
        //创建一个默认的线程池对象，池子中默认是空的，默认最多可以容纳int类型的最大值
        ExecutorService executorService = Executors.newCachedThreadPool();

        //借助executorService向池中放对象
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"zai执行");
        });

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"zai执行");
        });

        executorService.shutdown();// 关闭线程池
    }


}
